<?php
	if(!session_id()) {
	session_start();
	}
	
	$ini_array = parse_ini_file("includes/config.ini", true);
	$appName = $ini_array['application.basics']['application.name'];
	/*Database connection*/
	$localhost = $ini_array['database.connection']['db.localhost'];
	$user = $ini_array['database.connection']['db.user'];
	$password = $ini_array['database.connection']['db.password'];
	$db = $ini_array['database.connection']['db.dbname'];
	$link = mysql_connect($localhost, $user, $password);
	if (!$link) {
		die('Could not connect: ' . mysql_error());
	}
	//echo 'Connected successfully';

	
	$db_selected = mysql_select_db($db, $link);
	if (!$db_selected) {
		die ('Can\'t use foo : ' . mysql_error());
	}
	/*end database connection*/
	
	if(isset($_SESSION['uid'])) {
	$loggedIn=$_SESSION['uid'];
	}

	if(isset($loggedIn)){
		$userId = $_SESSION['uid'];
		$userName = $_SESSION['name'];
		$userPassword = $_SESSION['password'];
		$userType = $_SESSION['usertype'];
		$name = $_SESSION['name'];	
		$customerid = $_SESSION['customerid'];
		$distusertypeid = $_SESSION['usertypeid'];
		if($userType=='O')
		{
			$customer=$_SESSION['customer'];	
		}	
		elseif($userType=='C')
		{
			//$getcust=mysql_query("select * from cust_client cc, customer_master cm where cc.customer_id=cm.customer_id and cc.customer_id =".$customerid);
			//$getcustr=mysql_fetch_array($getcust);
			//extract($getcustr);
			//$customer=$getcustr['customer'];	
		}
		elseif($userType=='A')
		{
			$customer='';
		}
		else
		{
			$getcust=mysql_query("select * from user_master um, customer_master cm where um.customer_id=cm.customer_id and um.customer_id =".$customerid);
			while($getcustr=mysql_fetch_array($getcust))
			{
			
			$customer=$getcustr['customer'];
			}
		}
		if($userType=='A')
		{
			$userRole = "Administrator";
		}
		elseif($userType=='O')
		{
			$userRole = "Customer";
		}
		elseif($userType=='C')
		{
			$userRole = "Client";
		}
		elseif($userType=='V')
		{
			$userRole = "Vendor";
		}
		else
		{
			$userRole = "Resource";
		}
		
	}
	else {
		$userRole = "Visitor";
	}

	
?>
